﻿<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <title>病历管理</title>
    <?php PrintPageHead(); ?>
</head>
<body>
<style>
    table tr td{
        border: 1px #706e73 solid;
        text-align: left;
        padding: 4px;
    }
</style>

<?php

/**
 * Created by PhpStorm. User: ADun, Date: 14-10-15 下午10:11
 * Description:
 */
$openId=getCurrentUserOID();

if(empty($openId)) exit('参数错误');

$bm = new CUI数据中心(Page::m卖家中心_账目,$openId);

$床位 = $bm->se查看店铺已有床位();

?>

<div class="container-fluid">
    <?php include_once 'header.php'; ?>
    <div class="panel panel-primary">
        <div class="panel-heading text-center"><h3 class="panel-title">添加床位</h3></div>
        <div class="panel-body" style="width: 100%;">
            <div style="text-align:left; width: 90%; height: auto;margin-left: 4%">
                <span style="color: red;"><b>已有床位:</b></span>
                <span ><?php foreach($床位 as $value){
                        echo " &nbsp;".$value->data['床号']." |&nbsp; ";
                    }?></span>

            </div>
            <div style="text-align:left; width: 90%; height: auto;margin-left: 4%; margin-top: 5px;">
                <form action=""  method="post">
                   床位号: <input name="number" type="text">
                    <input type="submit" value="添加" name="add">
                </form>
            </div>
        </div>


    </div>



    <form>
        <input type="hidden" name="openId" value="<?=$openId?>" />
    </form>
</div>


</body>
</html>
<?php
if(isset($_POST['add'])){
    if($_POST['number'] ===''){
        echo "<script>alert('请填床位号');</script>";
    }else{

        $已存在床位 = pdo()->selectColumns('床位', array('id'),array('床号'=>$_POST['number'],'店铺id'=>$_SESSION['vo用户数据']['所属店铺id']));

        if($已存在床位){
            echo "<script>alert('该床位号已存在');</script>";
        }else{
            $do = new Do床位();
            $do->set_床号($_POST['number']);
            $do->set_店铺id($_SESSION['vo用户数据']['所属店铺id']);
            $插入 = $do->insert();
            if($插入){
                echo "<script>alert('添加床位成功');location.replace(location.href);</script>";
            }else{
                echo "<script>alert('添加床位失败');";
            }
        }



    }

}
?>